package bc.swim2.ejb.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({

		/**
		 * Query that return all the feedback in the database
		 */
		@NamedQuery(name = "Feedback.getWholeFeedbackList", query = "SELECT f FROM Feedback f"),
		/**
		 * Query that return all the feedbacks received from a user
		 */
		@NamedQuery(name = "Feedback.getFeedbackByReceiverId", query = "SELECT f FROM Feedback f WHERE f.receiverId = :id"), })
/**
 * Query that return all the feedbacks sent from a user
 */
// @NamedQuery(name = "Feedback.getFeedbackSentByUsername", query =
// "SELECT f FROM Feedback f WHERE f.sender = :username"),
/**
 * Query that return the average score obtained by a user in a
 * specificated ability
 */
// @NamedQuery(name = "Feedback.getAverageScoreByReceiverAndAbility", query =
// "SELECT avg(f.score) FROM Feedback f WHERE f.receiver = :username AND f.ability = :ability"),
/**
 * Query that return the average of the ratings issued by an user (in
 * all the ability)
 */
// @NamedQuery(name = "Feedback.getAverageScoreIssued", query =
// "SELECT avg(f.score) FROM Feedback f WHERE f.sender = :username"),
/**
 * Query that return the average of the ratings issued by an user to
 * another user(in all the ability)
 */
/*
 * @NamedQuery(name = "Feedback.getAverageScoreBySenderToReceiver", query =
 * "SELECT avg(f.score) FROM Feedback f" +
 * "WHERE f.sender = :sender AND f.receiver = :receiver"),
 */
/**
 * Query that return the average of the ratings issued by an user to
 * another user in a specified ability(in all the ability)
 */
// @NamedQuery(name = "Feedback.getAverageScoreBySenderToReceiverAbility", query
// = "SELECT avg(f.score) FROM Feedback f "
// +
// "WHERE f.sender = :sender AND f.receiver = :receiver AND f.ability = :ability")
// })
@Entity
@Table(name = "feedback")
public class Feedback implements Serializable {

	/**
	 * Default constructor
	 */
	public Feedback() {

	}

	/**
	 * constructor with all the parameters
	 * 
	 * @param id
	 * @param text
	 * @param score
	 * @param sender
	 * @param receiver
	 * @param ability
	 */

	public Feedback(int senderId, int receiverId, boolean score, int abilityId,
			String text) {
		this.text = text;
		this.score = score;
		this.senderId = senderId;
		this.receiverId = receiverId;
		this.abilityId = abilityId;
	}

	public Feedback(String user, boolean score, String abilityName, String text) {
	}

	private static final long serialVersionUID = 6589441154516984481L;

	/**
	 * Identification attribute for the entity Ability
	 */
	@Id
	@GeneratedValue
	@Column(name = "Id", nullable = false)
	protected int id;

	/**
	 * Attribute that represent the text of the feedback
	 */
	@Column(name = "Text", length = 1020)
	String text;

	/**
	 * Attribute that represent the score of the judge about the job
	 */
	@Column(name = "Score", nullable = false)
	boolean score;

	/**
	 * Attribute that represent the author of the message
	 */
	@Column(name = "SenderId")
	int senderId;

	/**
	 * Attribute that represent the receiver of the message
	 */
	@Column(name = "ReceiverId")
	int receiverId;

	/**
	 * Attribute that represent the ability to trial
	 */
	@Column(name = "AbilityId")
	int abilityId;

	/**
	 * Getter method for id
	 * 
	 * @return id
	 */
	public int getId() {
		return id;
	}

	/**
	 * Setter method for id
	 * 
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Getter method for text
	 * 
	 * @return text
	 */
	public String getText() {
		return text;
	}

	/**
	 * Setter method for text
	 * 
	 * @param text
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * Getter method for score
	 * 
	 * @return score
	 */
	public boolean getScore() {
		return score;
	}

	/**
	 * Setter method for score
	 * 
	 * @param score
	 */
	public void setScore(boolean score) {
		this.score = score;
	}

	/**
	 * Getter method for author
	 * 
	 * @return senderId
	 */
	public int getSenderId() {
		return senderId;
	}

	/**
	 * Setter method for author
	 * 
	 * @param senderId
	 */
	public void setSenderId(int senderId) {
		this.senderId = senderId;
	}

	/**
	 * Getter method for receiver
	 * 
	 * @return receiverId
	 */
	public int getReceiverId() {
		return receiverId;
	}

	/**
	 * Setter method for receiver
	 * 
	 * @param receiverId
	 */
	public void setReceiverId(int receiverId) {
		this.receiverId = receiverId;
	}

	/**
	 * Getter method for ability
	 * 
	 * @return abilityId
	 */
	public int getAbilityId() {
		return abilityId;
	}

	/**
	 * Setter method for ability
	 * 
	 * @param abilityId
	 */
	public void setAbilityId(int ability) {
		this.abilityId = ability;
	}
}
